#pragma once
#pragma warning(disable:4996)       // disable checked iterator errors http://msdn.microsoft.com/en-us/library/aa985965(VS.80).aspx 

//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101

#include <Macros.h>
#include <CoVector.h>
#include <CoMatrix.h>
#include <CoCube.h>
#include <ValueHelpers.h>
#include <Settings.h>

#include <gen/QL/TermStructure.h>
#pragma unmanaged 
#include <ql\termstructures\yieldtermstructure.hpp>
#include <boost/smart_ptr/detail/spinlock.hpp>
#pragma managed 

using namespace System;
using namespace QuantLib;
using namespace Cephei;

using namespace Cephei::QL;
using namespace Cephei::QL::Times;
#define HANDLE
#define ABSTRACT
#undef STRUCT
namespace Cephei { namespace QL { namespace Termstructures {
	//////////////////////////////////////////////////////////////////////////////////////////////
	// implementation of IYieldTermStructure
	public ref class CYieldTermStructure : 
            public CTermStructure,
            public Cephei::QL::Termstructures::IYieldTermStructure
	{
	protected: 
		boost::shared_ptr<QuantLib::YieldTermStructure>* _ppYieldTermStructure;
#ifdef HANDLE
		QuantLib::Handle<QuantLib::YieldTermStructure>* _phYieldTermStructure;
#endif
		Object^ _YieldTermStructureOwner;     // reference to object that manages the storage for this object
	internal:
        CYieldTermStructure (boost::shared_ptr<QuantLib::YieldTermStructure>& childNative, Object^ owner);
        CYieldTermStructure (QuantLib::YieldTermStructure& childNative, Object^ owner);
        CYieldTermStructure (CYieldTermStructure^ copy);
        CYieldTermStructure (System::Type^ t);
#ifdef STRUCT
        CYieldTermStructure (QuantLib::YieldTermStructure childNative);
#endif       
#ifdef HANDLE
		CYieldTermStructure (QuantLib::Handle<QuantLib::YieldTermStructure>& childNative, Object^ owner);
		CYieldTermStructure (QuantLib::Handle<QuantLib::YieldTermStructure> childNative);
#endif
		virtual ~CYieldTermStructure ();
		!CYieldTermStructure ();

	internal:
		QuantLib::YieldTermStructure& GetReference ();
		boost::shared_ptr<QuantLib::YieldTermStructure>& GetShared ();
		QuantLib::YieldTermStructure* GetPointer ();
        void SetYieldTermStructure (boost::shared_ptr<QuantLib::YieldTermStructure> native)
        {
            if (_ppYieldTermStructure != NULL)
                delete _ppYieldTermStructure;
            _ppYieldTermStructure = new boost::shared_ptr<QuantLib::YieldTermStructure> (native);
            SetTermStructure (boost::dynamic_pointer_cast<QuantLib::TermStructure> (*_ppYieldTermStructure));
        }
#ifdef HANDLE
		QuantLib::Handle<QuantLib::YieldTermStructure>& GetHandle ();
#endif
		virtual bool HasNative () override;
    public:
        property Cephei::IVector<DateTime>^ JumpDates 
        {
		    virtual Cephei::IVector<DateTime>^ get () ;
        }
        property Cephei::IVector<Double>^ JumpTimes 
        {
		    virtual Cephei::IVector<Double>^ get () ;
        }
		virtual Double Discount (Double t, Microsoft::FSharp::Core::FSharpOption<Boolean>^ extrapolate) ;
		virtual Double Discount (DateTime d, Microsoft::FSharp::Core::FSharpOption<Boolean>^ extrapolate) ;
		virtual Cephei::QL::IInterestRate^ ForwardRate (Double t1, Double t2, QL::CompoundingEnum comp, Microsoft::FSharp::Core::FSharpOption<QL::Times::FrequencyEnum>^ freq, Microsoft::FSharp::Core::FSharpOption<Boolean>^ extrapolate) ;
		virtual Cephei::QL::IInterestRate^ ForwardRate (DateTime d, Cephei::QL::Times::IPeriod^ p, Cephei::QL::Times::IDayCounter^ resultDayCounter, QL::CompoundingEnum comp, Microsoft::FSharp::Core::FSharpOption<QL::Times::FrequencyEnum>^ freq, Microsoft::FSharp::Core::FSharpOption<Boolean>^ extrapolate) ;
		virtual Cephei::QL::IInterestRate^ ForwardRate (DateTime d1, DateTime d2, Cephei::QL::Times::IDayCounter^ resultDayCounter, QL::CompoundingEnum comp, Microsoft::FSharp::Core::FSharpOption<QL::Times::FrequencyEnum>^ freq, Microsoft::FSharp::Core::FSharpOption<Boolean>^ extrapolate) ;
		virtual Cephei::QL::IInterestRate^ ZeroRate (Double t, QL::CompoundingEnum comp, Microsoft::FSharp::Core::FSharpOption<QL::Times::FrequencyEnum>^ freq, Microsoft::FSharp::Core::FSharpOption<Boolean>^ extrapolate) ;
		virtual Cephei::QL::IInterestRate^ ZeroRate (DateTime d, Cephei::QL::Times::IDayCounter^ resultDayCounter, QL::CompoundingEnum comp, Microsoft::FSharp::Core::FSharpOption<QL::Times::FrequencyEnum>^ freq, Microsoft::FSharp::Core::FSharpOption<Boolean>^ extrapolate) ;
        property Cephei::QL::Termstructures::IYieldTermStructure^ Update 
        {
		    virtual Cephei::QL::Termstructures::IYieldTermStructure^ get () ;
        }
    };
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Factory class
	public ref class CYieldTermStructure_Factory : public System::MarshalByRefObject,  public IYieldTermStructure_Factory
	{
	public:
    };
   
/*Cephei*/ } /*QL*/ } /*Termstructures */}
